<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script>
    <style type="text/css">
        .header {
            padding: 2.5rem 0.5rem 2rem 0.5rem;
        }
    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="padding-top:25px;">
        <a class="aui-pull-left aui-btn" onclick="closeWin()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">E文通</div>
        <a class="aui-pull-right aui-btn nav-btn">
        </a>
    </header>
<div class="head-d"></div>
    <ul class="list-t">
        <li class="signListBtn active" id="signNum" onclick="signListBtn(1);" id="signListBtn">已浏览(0)</li>
        <li class="signListBtn" id="unsignNum" onclick="signListBtn(2);" id="unsignListBtn">未浏览(0)</li>
    </ul>

    <div id="list"></div>
</body>

<script type="text/template" id="template1">
    <ul class="list signList">
        {{~it:value:index}}
        <li>
            <img src="./image/gril.jpg">
            <dl>
                <dt>{{=value.name}}</dt>
                <dd>浏览时间：{{=value.sign_date}}</dd>
                <dd>部门：{{=value.dept_name}}</dd>
                <dd>职位：{{=value.position_name}}</dd>
            </dl>
        </li>
        {{~}}
    </ul>
</script>

<script type="text/template" id="template2">
    <ul class="list unsignList">
        {{~it:value:index}}
        <li>
            <img src="./image/gril.jpg">
            <dl>
                <dt>{{=value.name}}</dt>
                <dd>部门：{{=value.dept_name}}</dd>
                <dd>职位：{{=value.position_name}}</dd>
            </dl>
        </li>
        {{~}}
    </ul>
</script>

<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript">
    function openClub() {
        var delay = 0;
        if (api.systemType != 'ios') {
            delay = 300;
        }
        api.openWin({
            name: 'club_win',
            url: './html/club_win.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false,
            progress: {
                type: "page"
            }
        });
    }
    $(".nav-btn").on("click", function() {
        $(".nav").slideToggle(100);
    })
    $(".nav .aui-list-item").on("click", function() {
        $(".nav").hide();
    })

    function closeWin() {
        api.closeWin({});
    }

    var type = 1;
    var id = '';
    apiready = function() {
        id = api.pageParam.id;
        updateData(id);
    }

    function signListBtn(num) {

        if (type == num) {
            return;
        }
        if (num == 1) {
            type = 1;
            $(".signListBtn").removeClass("active");
            $("#signListBtn").addClass('active');
            $(".unsignList").remove();
            updateData(id);
        }
        if (num == 2) {
            type = 2;
            $(".signListBtn").removeClass("active");
            $("#unsignListBtn").addClass('active');
            $(".signList").remove();
            updateData(id);
        }
    }

    function updateData(conid) {
        api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: '努力加载中...',
            text: '先喝杯茶...',
            modal: false
        });

        var userid = $api.getStorage('id');

        var url = 'http://oa.big-wealth.com/index.php?m=&c=info&a=sign_report_api&api_auth_id=' + userid + '&id=' + conid;
        // console.log(url);
        api.ajax({
            url: url,
            method: 'get',

        }, function(ret, err) {
            if (ret) {
                // alert(JSON.stringify(ret.un_sign_user_info.length));
                if (ret.signed_user_info == 0 || ret.signed_user_info == "" || ret.signed_user_info == null) {
                    $("#signNum").text("已浏览(0)");
                } else {
                    $("#signNum").text("已浏览(" + ret.signed_user_info.length + ")");
                }

                if (ret.un_sign_user_info == 0 || ret.un_sign_user_info == "" || ret.un_sign_user_info == null) {

                    $("#unsignNum").text("未浏览(0)");
                } else {

                    $("#unsignNum").text("未浏览(" + ret.un_sign_user_info.length + ")");
                }

                if (type == 1) {
                    templateFun(ret.signed_user_info);
                } else {
                    templateFun(ret.un_sign_user_info);
                }

                api.hideProgress();
            } else {
                // alert(JSON.stringify(err));
            }
        });

    }

    function templateFun(data) {

        if (data == '') {
            api.toast({
                msg: '没有内容！',
                duration: 1500,
                location: 'middle'
            });
        }

        var temID = "template" + type;

        var template = $api.byId(temID);
        var dotFn = doT.template(template.innerHTML);
        var html = dotFn(data);
        var list = $api.byId('list');
        $api.html(list, html);

    }
</script>

</html>
